<!doctype html><html xmlns="http://www.w3.org/1999/xhtml" id="html">
    <head>
        <title></title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <base href="<?= base_url(1); ?>" />
        <link type="text/css" href="css/main.css?v=<?= $config['version'] ?>" rel="stylesheet" />
    </head>
    <body>
        <?php include(VIEWPATH . 'common/main_header.php'); ?>
        <div class="datalist"><table id="flexigrid" style="display:none"></table></div>
        <script type="text/javascript">
            $(function() {
                $("#flexigrid").flexigrid($.extend(SG.flexOptions, {
                    url: '<?= site_url('activity/giftbag/flexigrid') ?>',
                    colModel: [
                        {display: '<?= translate('ID') ?>', name: 'id', width: 100},
                        {display: '<?= translate('ACTIVITY_GIFTBAG_NAME') ?>', name: 'name', width: 300},
                        {display: '<?= translate('ACTIVITY_GIFTBAG_USEDLEVEL') ?>', name: 'usedlevel', width: 100, hide:'true'},
                        {display: '<?= translate('ACTIVITY_GIFTBAG_ACTOBJECT') ?>', name: 'actobject', width: 100, hide:'true', process: formatActObject},
                        {display: '<?= translate('ACTIVITY_GIFTBAG_OBJECTICON') ?>', name: 'objecticon', width: 100},
                        {display: '<?= translate('ACTIVITY_GIFTBAG_KIND') ?>', name: 'kind', width: 100,process: formatKind, hide:'true'},
                        {display: '<?= translate('ACTIVITY_GIFTBAG_SUBKIND') ?>', name: 'subkind', width: 100, hide:'true'},
                        {display: '<?= translate('ACTIVITY_GIFTBAG_COLOR') ?>', name: 'color', width: 100,process: formatColor, hide:'true'},
                        {display: '<?= translate('ACTIVITY_GIFTBAG_WEIGHT') ?>', name: 'weight', width: 100, hide:'true' },
                        {display: '<?= translate('ACTIVITY_GIFTBAG_STACKLIMIT') ?>', name: 'stacklimit', width: 100, hide:'true' },
                        {display: '<?= translate('ACTIVITY_GIFTBAG_BAGLIMIT') ?>', name: 'baglimit', width: 100, hide:'true', process: formatBagLimit},
                        {display: '<?= translate('ACTIVITY_GIFTBAG_GETTYPE') ?>', name: 'gettype', width: 100, hide:'true', process: formatGetType},
                        {display: '<?= translate('ACTIVITY_GIFTBAG_BUYGOLD') ?>', name: 'buygold', width: 100, hide:'true' },
                        {display: '<?= translate('ACTIVITY_GIFTBAG_SELLGOLD') ?>', name: 'sellgold', width: 100, hide:'true' },
                        {display: '<?= translate('ACTIVITY_GIFTBAG_VALIDTIME') ?>', name: 'validtime', width: 100, hide:'true'},
                        {display: '<?= translate('ACTIVITY_GIFTBAG_CANDECOMPOSE') ?>', name: 'candecompose', width: 100, hide:'true' },
                        {display: '<?= translate('ACTIVITY_GIFTBAG_DESCRIBE') ?>', name: 'describe', width: 300},
                        {display: '<?= translate('MANAGE') ?>', name: 'id', width: 100, sortable: false, process: formatOp, toggle: false}
                    ],
                    buttons: [
                        {name: 'add', displayname: "<?= translate('ADD') ?>", title: "<?= translate('ADD') ?>", bclass: 'add', onpress: multi},
                        {name: 'export', displayname: "<?= translate('EXPORT') ?>", bclass: 'export', onpress: multi},
                        {name: 'delete', displayname: "<?= translate('DEL') ?>", title: "<?= translate('DEL') ?>", bclass: 'delete', onpress: multi},
                        {separator: true}
                    ],
                    searchitems: true,
                }));
                SG.admin = $.extend(SG.admin, {
                    add_url: '<?= site_url("activity/giftbag/add") ?>',
                    del_url: '<?= site_url("activity/giftbag/del/") ?>',
		    		edit_url: '<?= site_url("activity/giftbag/edit/") ?>',
                    //multi_url: '<?= site_url("activity/giftbag/multi/") ?>'
                });

                function formatActObject(value, id, cell, field) {
                    var typearr = <?= json_encode($actobjectlist); ?>;
                    var arr = [];
                    
                    $.each(typearr, function(i, j) {
                        var color = i == 'hide' ? 'gray' : (i == 'new' ? 'red' : (i == 'prepare' ? 'green' : (i == 'close' ? 'gray' : '')))
                        arr.push({color: color, text: j, value: i});
                    });
                    return filterGeneral(arr, value, field);
                } 
                function formatKind(value, id, cell, field) {
                    var typearr = <?= json_encode($kindlist); ?>;
                    var arr = [];
                    
                    $.each(typearr, function(i, j) {
                        var color = i == 'hide' ? 'gray' : (i == 'new' ? 'red' : (i == 'prepare' ? 'green' : (i == 'close' ? 'gray' : '')))
                        arr.push({color: color, text: j, value: i});
                    });
                    return filterGeneral(arr, value, field);
                } 
                function formatColor(value, id, cell, field) {
                    var typearr = <?= json_encode($colorlist); ?>;
                    var arr = [];
                    
                    $.each(typearr, function(i, j) {
                        var color = i == 'hide' ? 'gray' : (i == 'new' ? 'red' : (i == 'prepare' ? 'green' : (i == 'close' ? 'gray' : '')))
                        arr.push({color: color, text: j, value: i});
                    });
                    return filterGeneral(arr, value, field);
                } 
                function formatBagLimit(value, id, cell, field) {
                    var typearr = <?= json_encode($baglimitlist); ?>;
                    var arr = [];
                    
                    $.each(typearr, function(i, j) {
                        var color = i == 'hide' ? 'gray' : (i == 'new' ? 'red' : (i == 'prepare' ? 'green' : (i == 'close' ? 'gray' : '')))
                        arr.push({color: color, text: j, value: i});
                    });
                    return filterGeneral(arr, value, field);
                } 
                function formatGetType(value, id, cell, field) {
                    var typearr = <?= json_encode($gettypelist); ?>;
                    var arr = [];
                    
                    $.each(typearr, function(i, j) {
                        var color = i == 'hide' ? 'gray' : (i == 'new' ? 'red' : (i == 'prepare' ? 'green' : (i == 'close' ? 'gray' : '')))
                        arr.push({color: color, text: j, value: i});
                    });
                    return filterGeneral(arr, value, field);
                } 
            });
        </script>
    </body>
</html>